# 注：因为这个测试更改了手机验证码，所以需要在本地运行

Feature: 作为一个律团用户
我可以拥有一个律团的账号
这样我就可以看到受保护的页面

# 注册失败

Scenario: 注册失败，因为手机号码格式不对
Given http "accept" header is "application/json"  
    And http "content-type" header is "application/json"
    And I make a "post" request to "register" with:
    | account_type    | username | password |
    | phone                 | 137023     |  testsdfsdaf |
    And the response is in "json" format
    Then the response status code should be 400
    And I got error message "手机号格式不正确" for field "username"

Scenario: 注册失败，因为邮箱格式不对
Given http "accept" header is "application/json"  
    And http "content-type" header is "application/json"
    And I make a "post" request to "register" with:
    | account_type    | username | password |
    | email                 | 13702303211    |  testdfsdaf |
    And the response is in "json" format
    Then the response status code should be 400
    And I got error message "邮箱格式不正确" for field "username"

Scenario: 注册失败，因为手机号码已经被别人使用了
Given http "accept" header is "application/json"  
    And http "content-type" header is "application/json"
    And I make a "post" request to "register" with:
    | account_type    | username | password |
    | phone                 | 13702325511          |  testsdfsdaf |
    And the response is in "json" format
    Then the response status code should be 400
    And I got error message "这个手机号已经注册了" for field "username"

Scenario: 注册失败，因为邮箱已经被别人使用了
Given http "accept" header is "application/json"  
    And http "content-type" header is "application/json"
    And I make a "post" request to "register" with:
    | account_type    | username | password |
    | email                 | 19096161@qq.com     |  testsdfsdaf |
    And the response is in "json" format
    Then the response status code should be 400
    And I got error message "这个邮箱已经注册了" for field "username"


# 注册成功

@local
Scenario: 成功使用手机号码注册
Given user with phone "13702325510" does not exist
    And valid phone code "111111" for phone number "13702325510"
    And I make a "post" request to "register" with:
    | account_type    | username      | password | phonecode |
    | phone           | 13702325510   | testsdfsdaf | 111111  |
    And the response is in "json" format
    And print last response
    Then the response status code should be 200

Scenario: 成功使用邮箱注册
Given user with email "19063415651@qq.com" does not exist
    And http "accept" header is "application/json"  
    And http "content-type" header is "application/json"
    And I make a "post" request to "register" with:
    | account_type    | username | password |
    | email                 | 19063415651@qq.com          |  testsdfsdaf |
    And the response is in "json" format
    And print last response
    Then the response status code should be 200
    And I got success message "用户已经成功注册。" for field "success_messages"

